ENV_FILE = .env
ifneq ("$(wildcard $(ENV_FILE))","")
    include $(ENV_FILE)
endif

APP_VERSION    ?= snapshot
UI_VERSION 		= $(shell node --print 'require("./ui/package.json").version')
SERVER_VERSION 	= $(shell ./srv/gradlew -p ./srv -q version)

ifneq ("$(DB_HOST)$(DB_PORT)", "")
	DATASOURCE_URL = jdbc:postgresql://$(DB_HOST):$(DB_PORT)/$(DB_NAME)
endif

# --------------- INFORMATION ---------------
print-env:
	@echo "-------------- ENVIRONMENT --------------"
	@echo "DATASOURCE-URL    : $(DATASOURCE_URL)"
	@echo "DB-USERNAME       : $(DB_USERNAME)"
	@echo "DB-PASSWORD       : $(DB_PASSWORD)"
	@echo "-----------------------------------------"

print-version: 
	@echo "---------------- VERSION ----------------"
	@echo "APP-VERSION       : $(APP_VERSION)"
	@echo "UI-VERSION        : $(UI_VERSION)"
	@echo "SERVER-VERSION    : $(SERVER_VERSION)"
	@echo "-----------------------------------------"

# ----------------- DATABASE ----------------
start-db:
	docker compose up --build -d db

stop-db:
	docker stop ${DB_NAME}-db
